package cloud.daodao.storm.common.security.error;

import cloud.daodao.storm.common.constant.ServiceCode;
import cloud.daodao.storm.common.error.ErrorEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author DaoDao
 */
@Getter
@AllArgsConstructor
public enum SecurityError implements ErrorEnum {

    ERROR(code("001"), "security 服务异常"),

    CAPTCHA_NOT_NULL(code("103"), "验证码不可为空"),
    CAPTCHA_EXPIRE(code("104"), "验证码过期"),
    CAPTCHA_ERROR(code("105"), "验证码错误"),
    GENERATE_CAPTCHA_ERROR(code("106"), "生成验证码异常"),

    AES_NOT_EXIST(code("002"), "AES 密钥不存在"),
    RSA_NOT_EXIST(code("003"), "RSA 密钥不存在"),
    SECRET_NOT_EXIST(code("004"), "密钥不存在"),
    AES_GENERATE_EXCEPTION(code("005"), "AES 密钥生成异常"),
    RSA_GENERATE_EXCEPTION(code("006"), "RSA 密钥生成异常"),
    AES_ENCRYPT_ERROR(code("209"), "AES 加密异常"),
    AES_DECRYPT_ERROR(code("210"), "AES 解密异常"),
    RSA_ENCRYPT_ERROR(code("213"), "RSA 加密异常"),
    RSA_DECRYPT_ERROR(code("214"), "RSA 解密异常"),
    RSA_SIGN_ERROR(code("215"), "RSA 签名异常"),
    RSA_VERIFY_ERROR(code("216"), "RSA 验签异常"),
    RSA_PUBLIC_KEY_ERROR(code("217"), "RSA 公钥异常"),
    RSA_PRIVATE_KEY_ERROR(code("218"), "RSA 私钥异常"),
    RSA_GENERATE_KEY_PAIR_ERROR(code("219"), "生成 RSA 密钥对儿异常"),
    RSA_EXTRACT_PUBLIC_KEY_ERROR(code("220"), "RSA 提取公钥异常"),

    ;

    /**
     * 错误编码
     */
    public final String code;

    /**
     * 错误信息
     */
    public final String message;

    private static String code(String code) {
        return ServiceCode.SECURITY + code;
    }

}
